package com.training.mapper;

import com.training.entity.PracticeEnrollment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;

@Mapper
public interface PracticeEnrollmentMapper {

    int insert(PracticeEnrollment enrollment);

    int updateStatus(@Param("id") Long id, @Param("studentId") Long studentId, @Param("status") String status);

    /**
     * A more general update method for re-enrollment.
     * @param enrollment The enrollment object with updated details.
     * @return The number of affected rows.
     */
    int updateEnrollment(PracticeEnrollment enrollment);

    PracticeEnrollment findById(@Param("id") Long id);

    List<PracticeEnrollment> findByStudentId(@Param("studentId") Long studentId);

    Integer checkIfEnrolled(@Param("studentId") Long studentId, @Param("practiceId") Long practiceId);

    /**
     * Finds an enrollment record for a student and practice, regardless of status.
     * @param studentId The student's ID.
     * @param practiceId The practice's ID.
     * @return The PracticeEnrollment object if found, otherwise null.
     */
    PracticeEnrollment findByStudentAndPracticeIds(@Param("studentId") Long studentId, @Param("practiceId") Long practiceId);
}